package com.wanchuang.qhbb.adapter;



import android.content.Context;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wanchuang.qhbb.R;
import com.wanchuang.qhbb.help.GlideHelper;
import com.wanchuang.qhbb.proto.Mystock;

import java.util.List;

public class ChuRuNewAdapter extends BaseMultiItemQuickAdapter<ChuRuBean, BaseViewHolder> {
    public ChuRuNewAdapter(Context context, List<ChuRuBean> dataList) {
        super(dataList);
        addItemType(0, R.layout.item_title_machine);
        addItemType(1, R.layout.item_chu_ru);
    }

    @Override
    protected void convert(BaseViewHolder helper, ChuRuBean item) {
        // 根据返回的 type 分别设置数据
        switch (helper.getItemViewType()) {
            case 0:
                helper.setText(R.id.tv_gc_name, item.getTitle());
                break;
            case 1:
                Mystock.allocationLogList.List   data = item.getItem();
                if (data.getIsThird().equals("1"))  // 回拨
                {
                    helper.setText(R.id.tv_name, data.getRecipientName() + " 回拨 " + data.getMemberInitiator());
                } else {
                    helper.setText(R.id.tv_name, data.getMemberInitiator() + " 划拨 " + data.getRecipientName());
                }
                helper.setText(R.id.tv_goods_name,   data.getEquipmentNum() + "台 " +  data.getEquipment())
                        .setText(R.id.tv_time, data.getEquipmentTime())
                        .setText(R.id.tv_xing, data.getWord())
                        .setTextColor(R.id.tv_xing, Color.parseColor(data.getColour()));
                GlideHelper.INSTANCE.loadImage(helper.getView(R.id.iv_image), data.getLogo());
                break;
            default:
                break;
        }
    }
}